﻿@model CREAPA.Dominio.Contracheque
@{
    ViewBag.Title = "Processar";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<style>
		
		* {
			margin: 0;
			padding: 0;
		}

        fieldset.grupo {
			border: 0;
		}

		
		body, input, select, textarea, button {
			font-family: sans-serif;
			font-size: 1em;
		}

		.grupo:after {
			content: "."; 
			display: block; 
			height: 0;
			clear: both; 
			visibility: hidden;
		}

		.campo {
			margin-bottom: 1em;
		}
        
        .campo label {
			margin-bottom: 0.2em;
			color: #000;
			display: block;
            margin-left: 3px;
		}

		fieldset.grupo .campo {
			float: left;
			margin-right: 3em;
            margin-left: 3px;
		}

		.campo input[type="text"],
		.campo input[type="email"],
		.campo input[type="url"],
		.campo input[type="tel"] {
			padding: 0.2em;
			border: 1px solid #CCC;
			box-shadow: 2px 2px 2px rgba(0,0,0,0.2);
			display: block;
            width: 200%;
            margin-left: 3px;
		}
        .campo textarea {
			padding: 0.2em;
			border: 1px solid #CCC;
			box-shadow: 2px 2px 2px rgba(0,0,0,0.2);
			display: block;
            width: 525px;
            margin-left: 3px;
		}

		.campo select option {
			padding-right: 1em;
		}

		.campo input:focus, .campo select:focus, .campo textarea:focus {
			background: #ffffff;
		}

		.campo label.checkbox {
			color: #000;
			display: inline-block;
			margin-right: 1em;
		}
	
	</style>

@{
    if (TempData["cc"] != null) {

        string msg = @TempData["cc"].ToString();
        @TempData["cc"] = null;
    
        <script type="text/javascript" class="alert">

            alert('Dados Gravados com sucesso');

    </script>
    }
<br />

    }

<h2>Processar Contracheque</h2>

@using (Html.BeginForm("Processar", "Contracheque", FormMethod.Post,
          new { enctype = "multipart/form-data" }))
{
 @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Contracheque</legend> 
        <br />
        <fieldset class="grupo"> 
           
            @{                
                int mesAnterior = (DateTime.Today.Month)-1;
            }
        <div class="campo">
            Mês:
            @Html.DropDownListFor(model => model.Mes,
                      new SelectList(new List<SelectListItem> {
                      new SelectListItem{Value="1", Text="Janeiro"},                           
                      new SelectListItem{Value="2", Text="Fevereiro"},                           
                      new SelectListItem{Value="3", Text="Março"},                           
                      new SelectListItem{Value="4", Text="Abril"},                           
                      new SelectListItem{Value="5", Text="Maio"},                           
                      new SelectListItem{Value="6", Text="Junho"},                           
                      new SelectListItem{Value="7", Text="Julho"},                           
                      new SelectListItem{Value="8", Text="Agosto"},                           
                      new SelectListItem{Value="9", Text="Setembro"},                           
                      new SelectListItem{Value="10", Text="Outubro"},                           
                      new SelectListItem{Value="11", Text="Novembro"},                           
                      new SelectListItem{Value="12", Text="Dezembro"}}, "Value", "Text",mesAnterior))
        </div>
        
        <div class="campo">
            Ano:
            @Html.DropDownListFor(model => model.Ano,
                      new SelectList(new List<SelectListItem> {
                      new SelectListItem{Value=@DateTime.Now.Year.ToString(), Text=@DateTime.Now.Year.ToString()},                           
                      new SelectListItem{Value=(@DateTime.Now.Year-1).ToString(), Text=(@DateTime.Now.Year-1).ToString()}},                           
                                         "Value", "Text"))
        </div>

         <div class="campo">
            Folha:
            @Html.DropDownListFor(model => model.TipoFolha,
                      new SelectList(new List<SelectListItem> {
                      new SelectListItem{Value="1", Text="Mensal"},                           
                      new SelectListItem{Value="2", Text="Férias"},
                      new SelectListItem{Value="3", Text="13º Salário"}},                           
                                         "Value", "Text"))
        </div>
            
       </fieldset> 

        <fieldset class="grupo"> 
              
        <div class="campo">
             Selecione o arquivo: 
            <input type="file" name="FileUpload1"  />
            </div>
        </fieldset> 
        <p>
            <input type="submit" value="Processar" class="button"/>
            @Html.ActionLink("Voltar", "Index", null, new { @class = "button2" })
        </p>
    </fieldset>    
    
}


@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

    <script>
        jQuery(document).ready(function () {
            // verifica se existe algum elemento com a class
            if ($(".button").length) {
                // adiciona evento desabilitando o botão
                $(".button").on('click', function () {
                    $(this).attr({
                        disabled: true
                    });
                    // descobrindo o form pai e enviando
                    this.value = 'Enviando...';
                    $(this).parents('form:first').submit();
                });
            }
        });
</script>      
                


